package ne.aishuyuan.video;

import ne.aishuyuan.video.netty.client.NettyClient;
import ne.aishuyuan.video.view.Player;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean;
import uk.co.caprica.vlcj.factory.discovery.NativeDiscovery;

@SpringBootApplication
public class VideoApplication  implements CommandLineRunner {
    @Autowired
    private NettyClient nettyClient;

    public static void main(String[] args) {
        new NativeDiscovery().discover();
        SpringApplicationBuilder builder = new SpringApplicationBuilder(VideoApplication.class);
        builder.headless(false).run(args);
    }

    @Override
    public void run(String... args) throws Exception {
        this.player().load();
        nettyClient.start();
    }

    @Bean
    public Player player () {
        return  new Player();
    }

}
